/**
 *******************************************************************************
 * @FileName  : bb_api.h
 * @Author    : GaoQiu
 * @CreateDate: 2020-09-10
 * @Copyright : Copyright(C) GaoQiu
 *              All Rights Reserved.
 *
 *******************************************************************************
 *
 * The information contained herein is confidential and proprietary property of
 * GaoQiu and is available under the terms of Commercial License Agreement
 * between GaoQiu and the licensee in separate contract or the terms described
 * here-in.
 *
 * This heading MUST NOT be removed from this file.
 *
 * Licensees are granted free, non-transferable use of the information in this
 * file under Mutual Non-Disclosure Agreement. NO WARRENTY of ANY KIND is provided.
 *
 *******************************************************************************
 */
#ifndef BB_API_H_
#define BB_API_H_

/*!  Baseband frequency */
#define BB_TICK_PER_US           16

/*!  BaseBand us to tick. */
#define BB_US_TO_TICK(us)       ((us) * BB_TICK_PER_US)

/*!  BaseBand ms to tick. */
#define BB_MS_TO_TICK(ms)       ((ms) * 1000 * BB_TICK_PER_US)

/*!  BaseBand tick to us. */
#define BB_TICK_TO_US(tick)     ((tick) / BB_TICK_PER_US)

/*!  BaseBand packet head length. */
#define BB_PKT_HDR_LEN           4

typedef void (*IrqHandlerCback_t)(void);

/*!  Base-band Power level. */
typedef enum {
	/*VBAT*/
	BB_POWER_P10p46_dBm = 63, //  10.46 dbm
	BB_POWER_P10p29_dBm = 61, //  10.29 dbm
	BB_POWER_P10p01_dBm = 58, //  10.01 dbm
	BB_POWER_P9p81_dBm  = 56, //   9.81 dbm
	BB_POWER_P9p48_dBm  = 53, //   9.48 dbm
	BB_POWER_P9p24_dBm  = 51, //   9.24 dbm
	BB_POWER_P8p97_dBm  = 49, //   8.97 dbm
	BB_POWER_P8p73_dBm  = 47, //   8.73 dbm
	BB_POWER_P8p44_dBm  = 45, //   8.44 dbm
	BB_POWER_P8p13_dBm  = 43, //   8.13 dbm
	BB_POWER_P7p79_dBm  = 41, //   7.79 dbm
	BB_POWER_P7p41_dBm  = 39, //   7.41 dbm
	BB_POWER_P7p02_dBm  = 37, //   7.02 dbm
	BB_POWER_P6p60_dBm  = 35, //   6.60 dbm
	BB_POWER_P6p14_dBm  = 33, //   6.14 dbm
	BB_POWER_P5p65_dBm  = 31, //   5.65 dbm
	BB_POWER_P5p13_dBm  = 29, //   5.13 dbm
	BB_POWER_P4p57_dBm  = 27, //   4.57 dbm
	BB_POWER_P3p94_dBm  = 25, //   3.94 dbm
	BB_POWER_P3p23_dBm  = 23, //   3.23 dbm

	/* VANT */
	BB_POWER_P3p01_dBm  = BIT(7) | 63,   //   3.01 dbm
	BB_POWER_P2p81_dBm  = BIT(7) | 61,   //   2.81 dbm
	BB_POWER_P2p61_dBm  = BIT(7) | 59,   //   2.61 dbm
	BB_POWER_P2p39_dBm  = BIT(7) | 57,   //   2.39 dbm
	BB_POWER_P1p99_dBm  = BIT(7) | 54,   //   1.99 dbm
	BB_POWER_P1p73_dBm  = BIT(7) | 52,   //   1.73 dbm
	BB_POWER_P1p45_dBm  = BIT(7) | 50,   //   1.45 dbm
	BB_POWER_P1p17_dBm  = BIT(7) | 48,   //   1.17 dbm
	BB_POWER_P0p90_dBm  = BIT(7) | 46,   //   0.90 dbm
	BB_POWER_P0p58_dBm  = BIT(7) | 44,   //   0.58 dbm
	BB_POWER_P0p04_dBm  = BIT(7) | 41,   //   0.04 dbm
	BB_POWER_N0p14_dBm  = BIT(7) | 40,   //  -0.14 dbm
	BB_POWER_N0p97_dBm  = BIT(7) | 36,   //  -0.97 dbm
	BB_POWER_N1p42_dBm  = BIT(7) | 34,   //  -1.42 dbm
	BB_POWER_N1p89_dBm  = BIT(7) | 32,   //  -1.89 dbm
	BB_POWER_N2p48_dBm  = BIT(7) | 30,   //  -2.48 dbm
	BB_POWER_N3p03_dBm  = BIT(7) | 28,   //  -3.03 dbm
	BB_POWER_N3p61_dBm  = BIT(7) | 26,   //  -3.61 dbm
	BB_POWER_N4p26_dBm  = BIT(7) | 24,   //  -4.26 dbm
	BB_POWER_N5p03_dBm  = BIT(7) | 22,   //  -5.03 dbm
	BB_POWER_N5p81_dBm  = BIT(7) | 20,   //  -5.81 dbm
	BB_POWER_N6p67_dBm  = BIT(7) | 18,   //  -6.67 dbm
	BB_POWER_N7p65_dBm  = BIT(7) | 16,   //  -7.65 dbm
	BB_POWER_N8p65_dBm  = BIT(7) | 14,   //  -8.65 dbm
	BB_POWER_N9p89_dBm  = BIT(7) | 12,   //  -9.89 dbm
	BB_POWER_N11p4_dBm  = BIT(7) | 10,   //  -11.4 dbm
	BB_POWER_N13p29_dBm = BIT(7) | 8,    //  -13.29 dbm
	BB_POWER_N15p88_dBm = BIT(7) | 6,    //  -15.88 dbm
	BB_POWER_N19p27_dBm = BIT(7) | 4,    //  -19.27 dbm
	BB_POWER_N25p18_dBm = BIT(7) | 2,    //  -25.18 dbm

	BB_POWER_N30_dBm    = 0xff,          //  -30 dbm
	BB_POWER_N50_dBm    = BIT(7) | 0,    //  -50 dbm
}BB_Power_Type_t;


/**
 * @brief : Set RF TX power.
 * @param : pwr      can be BB_POWER_P3p01dBm ...
 * @return: none.
 */
void BB_SetTxPower(uint8_t pwr);

#endif /* BB_API_H_ */
